package com.wzy.springbootdemo.controller;

import com.wzy.springbootdemo.service.UserService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

@RestController
public class MybatisController {

    @Resource
    private UserService userService;

    @GetMapping("users")
    public Object users(){
        //多线程测试 begin
        Runnable runnable = new Runnable() {
            @Override
            public void run() {
                userService.getUsers();
            }
        };
        ExecutorService executorService = Executors.newFixedThreadPool(10);

        for (int i=0; i<10000; i++){
            executorService.submit(runnable);
        }
        //多线程测试 end
        return  userService.getUsers();
    }
}
